package com.sai.open.sky;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;

import com.skymobi.moposns.mutilopen.login.AcountInfo;
import com.skymobi.moposns.mutilopen.login.LoginUtil;
import com.mrpoid.utils.PLog;
import android.widget.Toast;
import android.content.Context;
import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.view.View.OnClickListener;
import android.view.View;
import com.skymobi.moposns.mutilopen.MultiOpenActivity;
import android.widget.EditText;
import com.skymobi.moposns.MoposnsLogoActivity;
import com.skymobi.plugin.api.fragment.FGUtil;
import com.skymobi.moposns.api.bean.AppInfo;
import com.skymobi.moposns.mutilopen.util.MrpConst;
import com.sai.open.BaseActivity;

public class LoginActivity extends BaseActivity implements View.OnClickListener, LoginUtil.LoginCallBack
{
	EditText nameEdit;
	EditText passEdit;
	AcountInfo info = null;

	//登录工具
	LoginUtil loginUtil = new LoginUtil();

	@Override
	public void onClick(View p1)
	{
		// TODO: Implement this method
		switch(p1.getId()){
			case R.id.p_game_login_btn:
				info.setUserName(nameEdit.getText().toString());
				info.setPassword(passEdit.getText().toString());
				loginUtil.login(info, this);
				
				
				showWaitingDialog("小蟀提示","登录中，请稍候。。。");
				break;
		}
	}

	@Override
	public void onLogin(boolean p1)
	{
		// TODO: Implement this method
		if(p1){
			finish();
		}else{
			Toast.makeText(this, "登录失败", Toast.LENGTH_SHORT).show();
		}
		waitingDialog.dismiss();
	}

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.pages_open);

		nameEdit = findViewById(R.id.p_login_name_edit);
		passEdit = findViewById(R.id.p_login_pass_edit);

		findViewById(R.id.p_game_login_btn).setOnClickListener(this);

		info = loginUtil.getSavedAcountInfo(this);
		if(info!=null){
			nameEdit.setText(info.getUserName());
			passEdit.setText(info.getPassword());
		}else
			info = new AcountInfo();
			
		changeFont();
    }

	
}
